﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.models.vo {
    import flash.events.*;

    public class AchievementVO {

        private var _id:String;
        private var _unlockedAtLevel:int;
        private var _rewards:Array;
        private var _completed:Boolean;
        private var _linkageID:String;
        private var _isLocked:Boolean;
        private var _eventDispatcher:EventDispatcher;
        private var _points:int;

        public function AchievementVO(_arg1:IEventDispatcher){
            this._rewards = [];
            super();
            this._eventDispatcher = EventDispatcher(_arg1);
        }
        public function addReward(_arg1:RewardVO):void{
            _arg1.eventDispatcher = this._eventDispatcher;
            _arg1.achievementVO = this;
            this._rewards.push(_arg1);
        }
        public function get id():String{
            return (this._id);
        }
        public function set id(_arg1:String):void{
            this._id = _arg1;
        }
        public function get unlockLevel():int{
            return (this._unlockedAtLevel);
        }
        public function set unlockLevel(_arg1:int):void{
            this._unlockedAtLevel = _arg1;
        }
        public function get rewards():Array{
            return (this._rewards);
        }
        public function get completed():Boolean{
            return (this.areAllRewardsCompleted());
        }
        public function set completed(_arg1:Boolean):void{
            this._completed = _arg1;
        }
        public function get linkageID():String{
            return (this._linkageID);
        }
        public function set linkageID(_arg1:String):void{
            this._linkageID = _arg1;
        }
        public function get isLocked():Boolean{
            return (this._isLocked);
        }
        public function set isLocked(_arg1:Boolean):void{
            this._isLocked = _arg1;
        }
        public function getLastReachedReward():RewardVO{
            var _local1:RewardVO;
            var _local2:int = this.rewards.length;
            while (_local2--) {
                _local1 = this.rewards[_local2];
                if (_local1.completed){
                    return (_local1);
                };
            };
            return (null);
        }
        public function getActiveReward():RewardVO{
            var _local1:RewardVO;
            var _local2:int;
            while (_local2 < this._rewards.length) {
                _local1 = this.rewards[_local2];
                if (!_local1.completed){
                    return (_local1);
                };
                _local2++;
            };
            return (_local1);
        }
        public function hasNotCollectedReachedRewards():Boolean{
            return ((this.getNotCollectedReachedRewards().length > 0));
        }
        public function getNotCollectedReachedRewards():Array{
            var _local2:RewardVO;
            var _local1:Array = [];
            for each (_local2 in this.rewards) {
                if (((_local2.completed) && (!(_local2.rewardCollected)))){
                    _local1.push(_local2);
                };
            };
            return (_local1);
        }
        private function areAllRewardsCompleted():Boolean{
            var _local2:RewardVO;
            var _local1:Boolean;
            for each (_local2 in this._rewards) {
                if (!_local2.completed){
                    _local1 = false;
                };
            };
            return (_local1);
        }
        public function set points(_arg1:int):void{
            this._points = _arg1;
        }
        public function get points():int{
            return (this._points);
        }

    }
}//package net.wooga.pets.models.vo 
